feat: archive fee - #1124
Open
DyferHerioss wants to merge 6 commits into
Open
Conversation
Mbomain
requested changes
Aug 12, 2026
| } from "react-admin"; | ||
| import {useToggle} from "../../../hooks"; | ||
|
|
||
| export const ArchiveWithConfirm: FC<{ |
Collaborator
There was a problem hiding this comment.
Don't use FC, it's deprecated
Comment on lines
+53
to
+55
| if (redirect) { | ||
| doRedirect(redirect); | ||
| } |
| } & Omit<ButtonProps, "children">; | ||
| } & {"data-testid"?: string} & Omit<ButtonProps, "children">; | ||
|
|
||
| export const FileDownloader: FC<FileDownloaderProps> = ({ |
| import {Informations} from "./profilContent/InformationContent"; | ||
| import {ProfileCardAvatar} from "./profilContent/ProfilCardAvatar"; | ||
|
|
||
| export const ProfileLayout: FC<{ |
| borderRadius="10px" | ||
| position="relative" | ||
| > | ||
| {/* Cover */} |
Comment on lines
+8
to
+94
| const sortByCreationDateDesc = (payments: Payment[]): Payment[] => | ||
| [...payments].sort( | ||
| (a, b) => | ||
| new Date(b.creation_datetime ?? 0).getTime() - | ||
| new Date(a.creation_datetime ?? 0).getTime() | ||
| ); | ||
|
|
||
| const fetchAllCreditPayments = async (): Promise<Payment[]> => { | ||
| const resultsByStatus = await Promise.all( | ||
| ALL_STATUSES.map((status) => | ||
| payingApi().getCreditPaymentsByStatus(status, 1, FETCH_ALL_PAGE_SIZE) | ||
| ) | ||
| ); | ||
|
|
||
| return sortByCreationDateDesc( | ||
| resultsByStatus.flatMap((result) => result.data) | ||
| ); | ||
| }; | ||
|
|
||
| type StudentInfo = {student_ref?: string; student_credit?: number}; | ||
|
|
||
| const findStudentInfoByPayment = async ( | ||
| payments: Payment[] | ||
| ): Promise<Map<string, StudentInfo>> => { | ||
| const feesResult = await payingApi().getFees( | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| 1, | ||
| FETCH_ALL_PAGE_SIZE | ||
| ); | ||
| const fees = feesResult.data.data ?? []; | ||
| const feeById = new Map(fees.map((fee) => [fee.id, fee])); | ||
|
|
||
| const studentIds = [ | ||
| ...new Set( | ||
| payments | ||
| .map((payment) => feeById.get(payment.fee_id!)?.student_id) | ||
| .filter((studentId): studentId is string => !!studentId) | ||
| ), | ||
| ]; | ||
|
|
||
| const credits = await Promise.all( | ||
| studentIds.map((studentId) => payingApi().getCreditByStudentId(studentId)) | ||
| ); | ||
|
|
||
| const creditByStudentId = new Map( | ||
| studentIds.map((studentId, index) => [ | ||
| studentId, | ||
| credits[index].data.amount, | ||
| ]) | ||
| ); | ||
|
|
||
| return new Map( | ||
| payments.map((payment) => { | ||
| const fee = feeById.get(payment.fee_id!); | ||
| return [ | ||
| payment.id!, | ||
| { | ||
| student_ref: fee?.student_ref, | ||
| student_credit: fee?.student_id | ||
| ? creditByStudentId.get(fee.student_id) | ||
| : undefined, | ||
| }, | ||
| ]; | ||
| }) | ||
| ); | ||
| }; | ||
|
|
||
| const enrichWithStudentInfo = async ( | ||
| payments: Payment[] | ||
| ): Promise<(Payment & StudentInfo)[]> => { | ||
| if (!payments.length) { | ||
| return []; | ||
| } | ||
|
|
||
| const studentInfoByPaymentId = await findStudentInfoByPayment(payments); | ||
|
|
||
| return payments.map((payment) => ({ | ||
| ...payment, | ||
| ...studentInfoByPaymentId.get(payment.id!), | ||
| })); | ||
| }; | ||
|
|
Comment on lines
+24
to
+68
| const studentCreditProvider: HaDataProviderType = { | ||
| getList: async (page, perPage, filter) => { | ||
| const studentId = filter.studentId as string; | ||
|
|
||
| const result = await payingApi().getCreditTransactionsByStudentId( | ||
| studentId, | ||
| filter as CreditMovement, | ||
| page, | ||
| perPage | ||
| ); | ||
|
|
||
| return { | ||
| data: result.data.map((transaction) => ({ | ||
| id: transaction.transaction_id, | ||
| transaction_id: transaction.transaction_id, | ||
| movement: transaction.movement, | ||
| amount: transaction.amount, | ||
| date_time: transaction.date_time, | ||
| fee: transaction.fee, | ||
| credit: transaction.credit, | ||
| })), | ||
| }; | ||
| }, | ||
| getOne: async (studentId) => { | ||
| const [creditResult, pendingCreditAmount] = await Promise.all([ | ||
| payingApi().getCreditByStudentId(studentId), | ||
| getPendingCreditAmount(studentId), | ||
| ]); | ||
|
|
||
| const credit = creditResult.data; | ||
|
|
||
| return { | ||
| ...credit, | ||
| amount: (credit.amount ?? 0) - pendingCreditAmount, | ||
| }; | ||
| }, | ||
| saveOrUpdate: () => { | ||
| throw new Error("Function not implemented."); | ||
| }, | ||
|
|
||
| delete: () => { | ||
| throw new Error("Function not implemented."); | ||
| }, | ||
| }; | ||
|
|
| } from "@mui/icons-material"; | ||
| import {Box} from "@mui/material"; | ||
|
|
||
| function ManagerMenu() { |
Collaborator
|
Many empty lines, and your test failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.